import React, { FC, useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { Space, Typography } from "antd";
import { FormOutlined } from "@ant-design/icons";
import styles from "./index.module.scss";
import useGetUserInfo from "../../hooks/useGetUserInfo";
import { HOME_PATHNAME, MANAGE_INDEX_PATHNAME } from "../../router";
const { Title } = Typography;
const Logo: FC = () => {
  const [pathname, setPathname] = useState(HOME_PATHNAME);
  const { username } = useGetUserInfo();
  //   console.log(username, "username:LOGIN");
  useEffect(() => {
    if (username) {
      setPathname(MANAGE_INDEX_PATHNAME);
    } else {
      setPathname(HOME_PATHNAME);
    }
  }, [username]);
  return (
    <div className={styles.container}>
      <Link to={pathname}>
        <Space>
          <Title className="!mb-0">
            <FormOutlined />
          </Title>
          <Title className="!mb-0">小b问卷</Title>
        </Space>
      </Link>
    </div>
  );
};
export default Logo;
